package com.ljq.cksp.controller;

import com.ljq.cksp.dao.BookDao;
import com.ljq.cksp.pojo.Result;
import com.ljq.cksp.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author:ljq
 * @Date:2020/4/17
 */
@RestController
@RequestMapping("/book")
public class BookController {
    @Autowired
    BookService bookService;

    @GetMapping
    public Result query(@RequestParam("keyword")String keyword){
        Result result = new Result();
        result.setData(bookService.query(keyword));
        return result;
    }

    @GetMapping("/{bookId}")
    public Result getBook(@PathVariable("bookId")int id){
        Result result = new Result();
        result.setData(bookService.get(id));
        return result;
    }
}
